﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Bangle.BLL
{
    public class UtilityBLL
    {
        private readonly Bangle.DAL.DBUtility dal = new Bangle.DAL.DBUtility();

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataTable GetListByPage(string TableName, string StrGetFields, string OrderField, string StrWhere, int PageSize, int PageIndex, int OrderType, out int RecordCount)
        {
            DataSet ds = new DataSet();
            ds = dal.GetListByPage(TableName, StrGetFields, OrderField, StrWhere, PageSize, PageIndex, OrderType);
            RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            return ds.Tables[1];
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataTable GetListByPage(string TableName, string StrGetFields, string OrderField, string StrWhere, int PageSize, int PageIndex)
        {
            int RecordCount = 0;
            return GetListByPage(TableName, StrGetFields, OrderField, StrWhere, PageSize, PageIndex, 1, out  RecordCount);
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataTable GetListByPage(string TableName, string StrGetFields, string OrderField, string StrWhere)
        {
            int RecordCount = 0;
            return GetListByPage(TableName, StrGetFields, OrderField, StrWhere, 100000, 1, 1, out  RecordCount);
        }
    }

    public class GridPagerModel
    {
        public string tableHtml { get; set; }
        public int pageSize { get; set; }
        public int pageIndex { get; set; }

        public int pageCount { get; set; }
    }

    public class AjexResponseModel
    {
        private int _state = 0;
        private string _msg = "";
        private string _error = "";
        private string _gridHtml = "";
        private int _pageSize = 0;
        private int _pageIndex = 0;
        private int _recordCount = 0;


        //1:返回成功 2:有异常 3:无权限 4:登录超时
        public int state
        {
            get { return _state; }
            set { _state = value; }
        }
        public string msg
        {
            get { return _msg; }
            set { _msg = value; }
        }
        public string error
        {
            get { return _error; }
            set { _error = value; }
        }
        public string gridHtml
        {
            get { return _gridHtml; }
            set { _gridHtml = value; }
        }
        public int pageSize
        {
            get { return _pageSize; }
            set { _pageSize = value; }
        }
        public int pageIndex
        {
            get { return _pageIndex; }
            set { _pageIndex = value; }
        }

        public int recordCound
        {
            get { return _recordCount; }
            set { _recordCount = value; }
        }
    }
}
